package umich.max.geolocation.featextract.counter;

import java.util.HashMap;

import max.nlp.dal.blog.blogger.BloggerBlog;
import max.nlp.dal.blog.blogger.BloggerPost;
import max.nlp.wrappers.ml.weka.WekaFeatureExtractor;

public class LIWCFeatureExtractor extends WekaFeatureExtractor<String, Integer> {

	private static String prefix = "liwc_";
	private LIWCCounter liwcCounter;

	public LIWCFeatureExtractor() {
		super(prefix);
		liwcCounter = LIWCCounter.getInstance();
	}

	public HashMap<String, Integer> extractFeaturesForObject(Object item) {
		BloggerBlog blog = (BloggerBlog) item;

		StringBuilder allText = new StringBuilder();
		
		//concatenate text together and then pass it to the counter. 
		for (BloggerPost post : blog.getPosts()) {
			allText.append(post.getCleanContent() + "\n\n");
		}
		HashMap<String, Integer> categoryCountsOfText = liwcCounter
				.getCategoryCountsOfText(allText.toString());
		return categoryCountsOfText;

	}

}
